#include <bits/stdc++.h>
// 2025/01/24
// tag: 
// Author: Zhang Muen
using namespace std;

int k, n, m, cow[1001];
bool vis[1001];
vector<int> graph[1001];

bool bfs(int u){
    int cnt = k;
    memset(vis, 0, sizeof(vis));
    queue<int> q;
    vis[u] = true;
    q.push(u);
    while (!q.empty()){
        int u = q.front();
        q.pop();
        cnt -= cow[u];
        for (int i = 0; i < graph[u].size(); i++){
            int v = graph[u][i];
            if (!vis[v])
                vis[v] = true, q.push(v);
        }
    }
    return cnt == 0;
}

signed main()
{
    cin >> k >> n >> m;
    for (int i = 1; i <= k; i++){
        int x;
        cin >> x;
        cow[x]++;
    }
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        graph[v].push_back(u);
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
        if (bfs(i))
            cnt++;
    cout << cnt;
    return 0;
}